<#include "../common/_layout.html"/>
<@layout>
<div class="ui-form ui-border-t">
    <form id="infoForm">
        <div class="ui-form-item ui-border-b">
            <label>标题 <font color="red">*</font></label>
            <input type="text" placeholder="标题 " name="info.title" value="${(info.title)!}" id="title">
            <input type="hidden" name="info.id" value="${(info.id)!}"/>
            <input type="hidden" name="info.type" value="2"/>
        </div>
        <div class="ui-form-item ui-border-b">
            <label>房源类别<font color="red">*</font></label>
            <div class="ui-select">
	            <select name="info.category" id="category">
	            	<option value="0">请选择</option>
	            	<option value="整套出租" <#if ((info.category)! == '整套出租')> selected </#if> >整套出租</option>
	            	<option value="单间出租" <#if ((info.category)! == '单间出租')> selected </#if> >单间出租</option>
	            	<option value="短租/日租" <#if ((info.category)! == '短租/日租')> selected </#if> >短租/日租</option>
	            	<option value="二手房" <#if ((info.category)! == '二手房')> selected </#if> >二手房</option>
	            	<option value="写字楼" <#if ((info.category)! == '写字楼')> selected </#if> >写字楼</option>
	            	<option value="商铺/生意" <#if ((info.category)! == '商铺/生意')> selected </#if> >商铺/生意</option>
	            	<option value="厂房/仓库" <#if ((info.category)! == '厂房/仓库')> selected </#if> >厂房/仓库</option>
	            </select>
	        </div>    
        </div>
        <div class="ui-form-item ui-form-item-textarea ui-border-b">
            <label>房源描述<font color="red">*</font></label>
            <textarea placeholder="房源描述" name="info.description" id="description">${(info.description)!}</textarea>
        </div>

        <div class="ui-form-item ui-border-b">
            <label>租金(元/月)<font color="red">*</font></label>
            <input type="text" placeholder="租金" name="info.price" value="${(info.price)!}" id="price"/>
        </div>
        
        <div class="ui-form-item ui-border-b">
            <label>房源地址<font color="red">*</font></label>
            <input type="text" placeholder="房源详细地址" name="info.address" value="${(info.address)!}" id="address"/>
        </div>
        <div class="ui-form-item ui-border-b">
            <label>联系人<font color="red">*</font></label>
            <input type="text" placeholder="联系人" name="info.contacts" value="${(info.contacts)!}" id="contacts"/>
        </div>
        <div class="ui-form-item ui-border-b">
            <label>联系电话<font color="red">*</font></label>
            <input type="text" name="info.mobile" placeholder="联系电话" value="${(info.mobile)!}" id="mobile">
        </div>
        <div class="ui-form-item ui-border-b">
            <label>联系QQ</label>
            <input type="text" name="info.qq" placeholder="联系QQ" value="${(info.qq)!}" id="qq">
        </div>
        <div class="ui-form-item ui-border-b">
            <label>起始日期</label>
            <input type="text" placeholder="20150520" name="startDateStr" value="${(info.startDateStr)!}"/>
        </div>
        <div class="ui-form-item ui-border-b">
            <label>截止日期</label>
            <input type="text" placeholder="20150521" name="endDateStr" value="${(info.endDateStr)!}"/>
        </div>

       	 <div class="ui-btn-wrap">
                <input type="button" class="ui-btn-lg ui-btn-primary" id="savebtn" onclick="save();" value="发布"/>
            </div>
    </form>
</div>

<script type="text/javascript">
	function save(){
		
		if(!$("#title").val()){
			tips("请填写标题");
			return false;
		}
		
		if($("#category").val() == 0){
			tips("请选择类别");
			return false;
		}
		
		if(!$("#description").val()){
			tips("请完善描述信息");
			return false;
		}
		
		if(!$("#price").val()){
			tips("请填写租金");
			return false;
		}
		
		if(!$("#address").val()){
			tips("请填写房源地址");
			return false;
		}
		
		if(!$("#contacts").val()){
			tips("请填写联系人");
			return false;
		}
		
		if(!$("#mobile").val()){
			tips("请填写联系电话");
			return false;
		}
		
		$.ajax({
	         type: "post",
	         url: "info/save",
	         data:$("#infoForm").serialize(),// 要提交的表单 
	         success:function(data){
	        	  var msg = data.msg;
		          if(data.code==200){
		        	  msg = "发布成功";
		              setTimeout(function(){window.location.href='/my';},1000);
		          }
		          
		          $.tips({
		  				content:msg,
		  				stayTime:1000,
		  				type:"info"
		  			});
		       }
	    });
	}
</script>
</@layout>